#!/bin/bash

# 获取物理内存使用量
mem_used=$(free -m | awk '/^Mem/{print $3}')

# 获取物理内存总量
mem_total=$(free -m | awk '/^Mem/{print $2}')

# 获取CPU核数
cpu_num=$(grep -c '^processor' /proc/cpuinfo)

# 获取平均负载
load_average=$(uptime | awk -F'[a-z]:' '{print $2}')

# 获取CPU使用率
cpu_usage=$(top -b -n 1 | awk '/^%Cpu/{print $2"% (User), "$4"% (System), "$10"% (Idle), "$8"% (I/O), "$6"% (Hardware interrupts), "$7"% (Software interrupts)"}')

echo "物理内存使用量(M): $mem_used"
echo "物理内存总量(M): $mem_total"
echo "CPU核数: $cpu_num"
echo "平均负载: $load_average"
echo "CPU使用率:"
echo "$cpu_usage"